/* 
请求工具函数的封装
*/
import axios from 'axios'
import useUserStore from '@/stores/modules/user'

const request = axios.create({
    baseURL: 'http://localhost:8080',
    timeout: 3000
})

request.interceptors.request.use((config) => {
    const userStore = useUserStore()
    if (userStore.token) {
        config.headers.accessToken = userStore.token
    }
    return config
})

request.interceptors.response.use((response) => {
    return response
}, (error) => {
    return Promise.reject(error)
})

export default request